<?php
namespace app\api\controller\assay;
use think\File;
use think\facade\Env;
use app\common\model\user\User as UserModel;
use app\common\model\company\Company;
use app\common\model\orderdata\Goods;
use app\common\model\quotation\QuotationList;
use app\common\model\rebate\RebateList;
use app\common\model\rebate\Rebate as RebateModel;
use app\api\controller\Base;
use app\api\controller\Baseuser;
use app\common\model\revenue_ap\Raplist as RapListModel;
use app\common\model\revenue_ap\Rap as RapModel;
use app\common\model\assay\Assaylist;

//化验管理 送样
class Assaypub extends Baseuser
{
	//初始化
    public function initialize(){
    	parent::initialize();
		// Rolepower::powerguard(101004);
	}
	
	public function test(){
		$sb = New Assaylist;
		$data = $sb->find();
		dump($data);
	}

	public function getlist(){
		$data = input('get.');
        $data = init_where($data,['time'=>'CreateTime']);
        $list = Assaylist::usergetlist($data);
        $filename = ['subuserinfo','accuserinfo','reguserinfo','companyinfo'];
        foreach ($list['list'] as $key => $value) {
        	foreach ($filename as $fkey => $fvalue) {
        		if (empty($value[$fvalue]['Name'])) {
	                 $list['list'][$key][$fvalue.'Name'] = '暂无';
	            } else {
	                $list['list'][$key][$fvalue.'Name'] = $value[$fvalue]['Name'];
	                unset($list['list'][$key][$fvalue]);
	            }
        	}
        }
        $list['tr']['title']  = ['企业名称','创建时间','订单状态','查看','送审时间','接收时间','登记时间','检测时间','送审人员','接收人员','登记人员'];
		$list['tr']['key'] = ['companyinfoName','CreateTime','State','AssayListId','SubTime','AccTime','RegTime','AssayTime','subuserinfoName','accuserinfoName','reguserinfoName'];
		$list['tr']['show']=[true,true,true,true,false,false,false,false];
		$list['option']['show_view_deletestate'] = true;
        return myok($list);
	}

	/**
	 * 获取送样详细信息 getreinfo
	 * @return [type] [description]
	 */
	public function getinfo(){
		$id = input('id');
		if(empty($id)){
			return myerr('缺少参数，请重新尝试');
		}
		$data = Assaylist::getinfo($id);
		if($data['code']){
			$data['msg']['companyinfo'] = Company::get($data['msg']['CompanyId'])->visible(['Name','Address']);
		}
		return myok($data);
	}

}
